package com.unitedvision.core.domain;

import java.util.Date;

public class Company {
	private int id;
	private Customer customer;
	private String description;
	private Date joinDate;
	private Status status;
	
	public Company() {
		super();
	}

	public Company(Customer customer, String description, Date joinDate, Status status) {
		super();
		this.customer = customer;
		this.description = description;
		this.joinDate = joinDate;
		this.status = status;
	}

	public Company(int id, Customer customer, String description, Date joinDate, Status status) {
		super();
		this.id = id;
		this.customer = customer;
		this.description = description;
		this.joinDate = joinDate;
		this.status = status;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getJoinDate() {
		return joinDate;
	}

	public void setJoinDate(Date joinDate) {
		this.joinDate = joinDate;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}
	
	public String getName() {
		return customer.getName();
	}
	
	public Address getAddress() {
		return customer.getAddress();
	}
	
	public Contact getContact() {
		return customer.getContact();
	}
	
	public boolean isActive() {
		return (status == Status.ACTIVE);
	}

	@Override
	public String toString() {
		return "Company [id=" + id + ", customer=" + customer
				+ ", description=" + description + ", joinDate=" + joinDate
				+ ", status=" + status + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((customer == null) ? 0 : customer.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + id;
		result = prime * result
				+ ((joinDate == null) ? 0 : joinDate.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Company other = (Company) obj;
		if (customer == null) {
			if (other.customer != null)
				return false;
		} else if (!customer.equals(other.customer))
			return false;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (id != other.id)
			return false;
		if (joinDate == null) {
			if (other.joinDate != null)
				return false;
		} else if (!joinDate.equals(other.joinDate))
			return false;
		if (status != other.status)
			return false;
		return true;
	}
}
